﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECONTACT.DataLayer
{
    public class HocKyData
    {
        DataService m_HocKyData = new DataService();

        public DataTable LayDsHocKy()
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM HOCKY");
            m_HocKyData.Load(cmd);
            return m_HocKyData;
        }

        public void LuuHocKy(String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_ThemHocKy");

            cmd.Parameters.Add("@TenHocKy", SqlDbType.NVarChar).Value = Ten;
            
            m_HocKyData.LoadProc(cmd);
        }

        public void UpdateHocKy(String MaHK, String Ten)
        {
            SqlCommand cmd = new SqlCommand("sp_CapNhatHocKy");

            cmd.Parameters.Add("@MaHK", SqlDbType.NVarChar).Value = MaHK;
            cmd.Parameters.Add("@TenHK", SqlDbType.NVarChar).Value = Ten;

            m_HocKyData.LoadProc(cmd);
        }

        public void DeleteHocKy(String MaHK)
        {
            SqlCommand cmd = new SqlCommand("sp_XoaHocKy");

            cmd.Parameters.Add("@MaHK", SqlDbType.NVarChar).Value = MaHK;

            m_HocKyData.LoadProc(cmd);
        }
    }
}
